package se.nestorthon.branding.server.webapp;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import se.nestorthon.branding.entity.Branding;
import se.nestorthon.branding.store.Store;
import se.nestorthon.branding.store.StoreInterface;

public class ListBrandingServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8011582339446589730L;

	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		StoreInterface store = Store.getInstance();
		StringBuffer brandings = new StringBuffer();
		int i = 0;
		for (Branding b : store.getBrandings())
		{
			brandings.append("<li id=\"");
			brandings.append(i++);
			brandings.append("<\">");
			
			brandings.append(b.getName());
			brandings.append("</li>");
		}
		req.setAttribute("BrandingList", brandings);
		req.getRequestDispatcher("index.jsp").forward(req, resp);
	}
}
